import java.util.ArrayList;
import java.util.Arrays;
/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 09 - 02
 * Time: 11:11
 */
//牛客 数据流中的中位数
public class Solution3 {
    //法一 官方推荐方法
    ArrayList<Integer> arrayList = new ArrayList<>();
    public void Insert(Integer num) {
        int i = 0;
        for (i = 0; i < arrayList.size(); i++) {
            if(num <= arrayList.get(i)) {
                break;
            }
        }
        arrayList.add(i, num);
    }
    public Double GetMedian() {
        int length = arrayList.size();
        if(length % 2 == 1) {
            return (double)arrayList.get(length / 2);
        }else {
            double a = arrayList.get(length / 2);
            double b = arrayList.get(length / 2 - 1);
            return (a + b) / 2;
        }
    }
}















